
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;

public class CellMeNu extends GameCanvas{
    int mauvien, maunen, mauchu;
    String text;
    int cao, rong;
    Image cellmenu;
    int bongang,bodoc;
    Font font;
    int x=0,y=0; //lưu toạ độ hiện tại của menu
    int IsFocus=0;
    
    public CellMeNu() {
        super(false);
    }

    public CellMeNu(String text, int rong, int cao, int mauchu,int mauvien, int maunen, int bongang, int bodoc) {
        super(false);
        
        font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_SMALL );
        this.text=text;
        this.rong=rong;
        this.cao=cao;
        this.mauchu=mauchu;
        this.mauvien=mauvien;
        this.maunen=maunen;
        this.bongang=bongang;
        this.bodoc=bodoc;
        cellmenu=Image.createImage(rong,cao);
        Graphics gmenu=cellmenu.getGraphics();
        gmenu.setFont(font);
        gmenu.setColor(maunen);
        gmenu.fillRoundRect(0, 0, rong-1, cao-1, bongang, bodoc);
        gmenu.setColor(mauvien);
        gmenu.drawRoundRect(0, 0, rong-1, cao-1, bongang, bodoc);
        gmenu.setColor(mauchu);
        gmenu.drawString(text, 10, 7, Graphics.TOP|Graphics.LEFT);
        
                
    }
    
    
    void VeCellMeNu(Graphics g,int x, int y)
    {
        this.x=x;
        this.y=y;
        g.drawImage(cellmenu, x, y, Graphics.TOP|Graphics.LEFT);
        flushGraphics();
    }
    void FocusMeNu(Graphics g)
    {
        IsFocus=1;
        Graphics gmenu=cellmenu.getGraphics();        
        gmenu.setColor(0x0000ff);
        gmenu.drawRoundRect(0, 0, rong-1, cao-1, bongang, bodoc);
        gmenu.drawRoundRect(1, 1, rong-3, cao-3, bongang-2, bodoc-2);
        VeCellMeNu(g, this.x, this.y);
                
    }
    void UnFocusMeNu(Graphics g)
    {
        IsFocus=0;
        Graphics gmenu=cellmenu.getGraphics();        
        gmenu.setColor(Mau.maunenct);
        gmenu.drawRoundRect(0, 0, rong-1, cao-1, bongang, bodoc);
        gmenu.drawRoundRect(1, 1, rong-3, cao-3, bongang-2, bodoc-2);
        gmenu.setColor(Mau.maudo);
        gmenu.drawRoundRect(0, 0, rong-1, cao-1, bongang, bodoc);
        VeCellMeNu(g, this.x, this.y);
        
    }
}  